package com.ruoyi.web.controller.laiqianba.member;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.MemberElementCountInfo;
import com.ruoyi.member.service.IMemberElementCountInfoService;
import com.ruoyi.web.wrapper.MemberElementCountInfoWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 三要素匹配统计Controller
 * 
 * @author ruoyi
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/member/elementCount")
public class MemberElementCountInfoController extends BaseController
{
    @Autowired
    private IMemberElementCountInfoService memberElementCountInfoService;

    /**
     * 查询三要素匹配统计列表
     */
    @PreAuthorize("@ss.hasPermi('member:elementCount:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberElementCountInfo memberElementCountInfo)
    {
        startPage();
        List<Map<String, Object>> list = memberElementCountInfoService.selectMemberElementCountInfoMapList(memberElementCountInfo);
        list = new MemberElementCountInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出三要素匹配统计列表
     */
    @PreAuthorize("@ss.hasPermi('member:elementCount:export')")
    @Log(title = "三要素匹配统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberElementCountInfo memberElementCountInfo)
    {
        List<MemberElementCountInfo> list = memberElementCountInfoService.selectMemberElementCountInfoList(memberElementCountInfo);
        ExcelUtil<MemberElementCountInfo> util = new ExcelUtil<MemberElementCountInfo>(MemberElementCountInfo.class);
        util.exportExcel(response, list, "三要素匹配统计数据");
    }

    /**
     * 获取三要素匹配统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:elementCount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(memberElementCountInfoService.selectMemberElementCountInfoById(id));
    }

    /**
     * 新增三要素匹配统计
     */
    @PreAuthorize("@ss.hasPermi('member:elementCount:add')")
    @Log(title = "三要素匹配统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberElementCountInfo memberElementCountInfo)
    {
        return toAjax(memberElementCountInfoService.insertMemberElementCountInfo(memberElementCountInfo));
    }

    /**
     * 修改三要素匹配统计
     */
    @PreAuthorize("@ss.hasPermi('member:elementCount:edit')")
    @Log(title = "三要素匹配统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberElementCountInfo memberElementCountInfo)
    {
        return toAjax(memberElementCountInfoService.updateMemberElementCountInfo(memberElementCountInfo));
    }

    /**
     * 删除三要素匹配统计
     */
    @PreAuthorize("@ss.hasPermi('member:elementCount:remove')")
    @Log(title = "三要素匹配统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(memberElementCountInfoService.deleteMemberElementCountInfoByIds(ids));
    }
}
